﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class GUI_Pages_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string connStr = ConfigurationManager.ConnectionStrings["CSConn"].ToString();
        SqlConnection conn = new SqlConnection(connStr);

        String s = Request.QueryString["bsID"];
        int bsID = Convert.ToInt32(s);

        SqlCommand cmd1 = new SqlCommand("SELECT Accounts.UserName, Accounts.DateCreated, Accounts.Approved, BabySitters.BSName, " +
        "BabySitters.DoB, BabySitters.CellNo, BabySitters.PhoneNo, BabySitters.EMail, BabySitters.Gender, " +
        "BabySitters.BS_Address, BabySitters.Area, BabySitters.PostalCode, BabySitters.Experience, " +
        "BabySitters.Essay, BabySitters.Allergies, BabySitters.Petconcern, Cities.CName, Nationalities.NName " +
        "FROM Accounts INNER JOIN BabySitters ON Accounts.AccountID = BabySitters.AccountID " +
        "INNER JOIN Cities ON BabySitters.CityID = Cities.CityID " +
        "INNER JOIN Nationalities ON BabySitters.NationalityID = Nationalities.NationalityID " +
        "WHERE BabySitters.BSID = @bsid", conn);
        cmd1.CommandType = CommandType.Text;
        cmd1.Parameters.Add(new SqlParameter("@bsid", bsID));
        //SqlDataAdapter ad = new SqlDataAdapter(cmd1);

        conn.Open();
        cmd1.ExecuteNonQuery();
        conn.Close();

        DataTable dt = new DataTable();
        SqlDataAdapter da = new SqlDataAdapter(cmd1);
        da.Fill(dt);
        TextBox1.Text = dt.Rows[0].Field<String>(3) +" , "+ dt.Rows[0].Field<DateTime>(4);
        DetailsView1.DataSource = dt;
        DetailsView1.DataBind();
    }
    
}